﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Moon.Sql
{
    public class UnitOfWorkManager : IUnitOfWorkManager
    {
        private IMoonSql[] _contexts;
        private IsolationLevel _isolationLevel;
        public UnitOfWorkManager(IMoonSql[] contexts, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
        {
            _contexts = contexts;
            _isolationLevel = isolationLevel;
        }

        public IUnitOfWork Begin()
        {
            IUnitOfWork unitOfWork = new UnitOfWork(_contexts);
            unitOfWork.IsolationLevel = _isolationLevel;
            unitOfWork.Begin();
            return unitOfWork;
        }
    }
}
